package com.viaje.action.ranking;

import javax.persistence.EntityManager;

import javax.persistence.EntityTransaction;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import com.opensymphony.xwork2.ActionSupport;

import com.viaje.common.util.*;
import com.viaje.model.Ranking;
@Action(value="/delete-ranking-*",
	params={"id","{1}"},
	results={@Result(name="exito",type="tiles", location="message.tiles")
} )

public class DeleteRankingAction  {
	private Long id;
	private String message;
	
	public String execute(){
		String result="exito";
		message="The lugar was removed successfully";
		EntityManager em= 
				Utilitario.getInstance().getEntityManager();
		EntityTransaction tx=em.getTransaction();
		try{
			tx.begin();
			Ranking ranking=em.find(Ranking.class, id);
			em.remove(ranking);
			tx.commit();
		}catch (Exception e) {
			e.printStackTrace();
			tx.rollback();
			message="No se pudo eliminar";
		}
		return result;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}	
}//FIN CLASS
